//
// Created by twetec on 25-6-21.
//

#include <network_prober/rpc/perception_rpc_client.h>

#include <network_prober/sys_config/sys_config.h>
#include <network_prober/database/file_db_model.h>

using network_prober::sys_config::SysConfig;

namespace network_prober::rpc
{
void PerceptionRPCClient::registerProber()
{
    // 注册探针(同步)
    m_RPCCallerRegisterProbe.call();
    // 指令处理程序(异步)
    std::jthread instructionThread(&PerceptionRPCCallerInstruction::call, &m_RPCCallerInstruction);
    // 接通观测结果上报连接(异步)
    std::jthread sustainProbeTargetThread(&PerceptionRPCCallerSustainProbeTarget::call, &m_RPCCallerSustainProbeTarget);
    // 持续上报探针服务器资源使用统计(异步)
    std::jthread sustainProbeInfoThread(&PerceptionRPCCallerSustainProbeInfo::call, &m_RPCCallerSustainProbeInfo);
    // 接通备份数据上报连接(异步)
    std::jthread backupDataReportThread(&PerceptionRPCCallerBackupDataReport::call, &m_RPCCallerBackupDataReport);
}

void PerceptionRPCClient::reportProbeTaskResultsToPerception(std::span<database::ProbeTaskResultModel> probeTaskResults)
{
    m_RPCCallerSustainProbeTarget.reportProbeTaskResults(probeTaskResults);
}

void PerceptionRPCClient::reportBackupTaskResultsToPerception(std::span<database::BackupTaskResultModel> backupTaskResults)
{
    m_RPCCallerBackupDataReport.reportBackupTaskResults(backupTaskResults);
}

PerceptionRPCClient& PerceptionRPCClient::getInstance()
{
    static PerceptionRPCClient instance;
    return instance;
}

PerceptionRPCClient::PerceptionRPCClient()
{
    
}

PerceptionRPCClient::~PerceptionRPCClient()
{

}


}
